package com.example.springboot1.Controller;

import com.example.springboot1.pojo.Article;
import com.example.springboot1.pojo.PageBean;
import com.example.springboot1.pojo.Result;
import com.example.springboot1.pojo.User;
import com.example.springboot1.service.ArticleService;
import com.example.springboot1.utils.JwtUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @PostMapping
    public Result add(@RequestBody Article article){
        articleService.add(article);
        return Result.success();
    }
    @GetMapping
    public Result<PageBean<Article>> list(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false) Integer categoryId,
            @RequestParam(required = false) String state
    ){
        PageBean<Article> pb =articleService.list(pageNum,pageSize,categoryId,state);
        return Result.success(pb);
    }


}
